﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace PaliTextReader2.Utilities
{
    class PaliKeyboard
    {
        static Keys[] arrKeys = new Keys[] { Keys.M, Keys.A, Keys.I, Keys.U, Keys.D, Keys.T, Keys.L, Keys.G, Keys.N, Keys.J };
        static char[] arrPaliChars = new char[] { 'ṃ', 'ā', 'ī', 'ū', 'ḍ', 'ṭ', 'ḷ', 'ṅ', 'ṇ', 'ñ' };

        public static void HandlePaliKeys(TextBox ctlSearchBox, KeyEventArgs e)
        {
            if (e.Modifiers == Keys.Alt)
            {
                for(int i=0;i<arrKeys.Length;i++)
                    if (arrKeys[i] == e.KeyCode)
                    {
                        int SelPos = ctlSearchBox.SelectionStart;
                        ctlSearchBox.Text = ctlSearchBox.Text.Insert(ctlSearchBox.SelectionStart, arrPaliChars[i].ToString());
                        ctlSearchBox.Select(SelPos + 1, 0);
                        break;
                    }
            }
        }

        public static void HandlePaliKeys(ComboBox ctlSearchBox, KeyEventArgs e)
        {
            if (e.Modifiers == Keys.Alt)
            {
                for (int i = 0; i < arrKeys.Length; i++)
                    if (arrKeys[i] == e.KeyCode)
                    {
                        int SelPos = ctlSearchBox.SelectionStart;
                        ctlSearchBox.Text = ctlSearchBox.Text.Insert(ctlSearchBox.SelectionStart, arrPaliChars[i].ToString());
                        //ctlSearchBox.Text += arrPaliChars[i];
                        ctlSearchBox.Select(SelPos + 1, 0);
                        break;
                    }
            }
        }
    }
}
